const brand = {
	async getAll() {
		const {
			data: res
		} = await uni.$http.get("/model/getAllModelInfo")
		if (res.code !== uni.$code.successCode) return uni.$showMsg(res.msg)
		return res.data
	},

	async getAllBrand() {
		const {
			data: res
		} = await uni.$http.get("brand/getBrandListAlphabet")
		if (res.code !== uni.$code.successCode) return uni.$showMsg(res.msg)
		res.data.forEach(x => {
			x.data.forEach(y => {
				y.imgSrc = uni.$staticResourcePath + y.imgSrc
			})
		})
		return res.data
	},

	async getAllModel(bid) {
		const {
			data: res
		} = await uni.$http.get("brand/getBrandModels?id=" + bid)
		if (res.code !== uni.$code.successCode) return uni.$showMsg(res.msg)
		res.data.models.forEach(x => {
			x.imgSrc = uni.$staticResourcePath + x.imgSrc
		})
		return res.data.models
	}
}

export default brand